//
//  SeparateContentCell.m
//  PigMarket
//
//  Created by 张敬 on 2019/8/14.
//  Copyright © 2019年 pigmarket.oc. All rights reserved.
//

#import "SeparateContentCell.h"

@implementation SeparateContentCell

#pragma mark - lifecycle methods

- (void)setupUI
{
    [self addSubview:self.titleLab];
    [self addSubview:self.contentLab];
    [self addSubview:self.tipLab];
    
}

- (void)setupLayout
{

    {
        _titleLab.size = CGSizeMake(80, 22);
        _titleLab.mj_x = 15;
        _titleLab.mj_y = 12;
        
        [_titleLab sizeToFit];
    }
    
    {
        _tipLab.size = CGSizeMake(200, 19);
        _tipLab.mj_x = 12+ _titleLab.right;
        _tipLab.mj_y = 12;
    }
    
    {
        _contentLab.frame = CGRectMake(0, 0, KScreenWidth - 30, 500);
         [_contentLab sizeToFit];
        _contentLab.mj_x = 15;
        _contentLab.mj_y = 40;
    }
}


#pragma mark - setter methods

- (void)setItem:(ShopSeparatePlanItem *)item{
    
    _titleLab.text = item.divisionPlanName;
    
    NSString *htmlString = item.content;
    NSAttributedString *attrStr = [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
    _contentLab.attributedText = attrStr;
    
    [self setupLayout];

}


#pragma mark - getter methods

- (UILabel *)titleLab{
    
    if (!_titleLab) {
        _titleLab = [UILabel makeLabelWithText:@"" textColor:UIColorFromRGB(0x262626) font:mFont(16) textAliment:0];
    }
    return _titleLab;
}


- (UILabel *)contentLab{
    
    if (!_contentLab) {
        _contentLab = [UILabel makeLabelWithText:@"" textColor:UIColorFromRGB(0x808080) font:mFont(14) textAliment:0];
//        NSMutableAttributedString *aims = [_contentLab.text getParagraphAttributedStringWithLineSpacing: 5];
//        _contentLab.attributedText = aims;
        _contentLab.numberOfLines = 0;
    }
    return _contentLab;
}


- (UILabel *)tipLab{
    
    if (!_tipLab) {
        _tipLab = [UILabel makeLabelWithText:@"不要下水、头、蹄，送200元豚券" textColor:KWhiteColor font:mFont(11) textAliment:1];
        [self addShadowAndCircleCorner:_tipLab.layer corner:9.5];
        _tipLab.backgroundColor = UIColorFromRGB(0xFF8A00);
    }
    return _tipLab;
}

@end
